package com.zzyk.microCloud.api.controller;

import com.zzyk.main.configuration.exception.UserException;
import com.zzyk.main.service.DeviceOriginDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api/historyData")
public class ApiHistoryDataController extends ApiBaseController {

    @Autowired
    private DeviceOriginDataService dataService;

/*    @RequestMapping("getHistoryDataByParam")
    public DateAndStringAndParam getHistoryDataByParam(@RequestParam("param") String param,
                                         @RequestParam("dId") Integer dId,
                                         @RequestParam("type") Integer type,
                                         @RequestParam("beginTime") String beginTime,
                                         @RequestParam("endTime") String endTime) throws UserException {
        DateAndStringAndParam data=new DateAndStringAndParam();
        data.setData(originDataService.findDeviceOriginData(,dId,param,beginTime,endTime,type));
        data.setParam(param);
        return data;
    }*/

    /**
     * 获取历史数据
     *
     * @param dId
     * @param param
     * @return
     */
    @GetMapping("/getHistoryDataByParam")
    public Map<String, Object> getHistoryDataByParam(Integer dId, String param, String beginDate, String endDate, Integer type) throws UserException {
        Map map = new HashMap(2);
        map.put("data", dataService.findDeviceOriginData(getUser().getSysUser().getEnterprise(), dId, param, beginDate, endDate, type));
        map.put("param", param);
        return map;
    }
}
